
var fs = require('fs'); //引入node.js(需要在main.js中全局引入:webPreferences:{ nodeIntegration:true})
window.onload = function(){//监听页面
    var btn = this.document.querySelector('#btn') //获取按钮
    var mybaby = this.document.querySelector('#mybaby') //获取显示的div
    btn.onclick = function(){ //点击按钮监听
        fs.readFile('xiaojiejie.txt',(err,data)=>{ //读取文件(默认项目根目录)
            mybaby.innerHTML = data //赋值
        })
    }
} 